home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue66 / XMLXSLT / ASPEx / simple_transform.asp < prev   
Encoding:
Text File  |  2000-12-13  |  1.5 KB  |  53 lines

  1. <%@LANGUAGE="VBScript"%>
  2.  
  3. <%
  4. Response.ContentType = "text/html"
  5.  
  6. Sub ShowError(objDoc)
  7.   'create and display error message
  8.   Dim strError
  9.   strError = "Invalid XML file !<BR />" _
  10.            & "File URL: " & objDoc.parseError.url & "<BR />" _
  11.            & "Line No.: " & objDoc.parseError.line & "<BR />" _
  12.            & "Character: " & objDoc.parseError.linepos & "<BR />" _
  13.            & "File Position: " & objDoc.parseError.filepos & "<BR />" _
  14.            & "Source Text: " & objDoc.parseError.srcText & "<BR />" _
  15.            & "Error Code: " & objDoc.parseError.errorCode & "<BR />" _
  16.            & "Description: " & objDoc.parseError.reason
  17.   Response.Write strError
  18. End Sub
  19.  
  20. Dim objXML
  21. Dim objXSL
  22.  
  23. 'create two document instances
  24. Set objXML = Server.CreateObject("Microsoft.XMLDOM")
  25. Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
  26.  
  27. 'set the parser properties
  28. objXML.ValidateOnParse = True
  29. objXSL.ValidateOnParse = True
  30.  
  31. 'load the source XML document and check for errors
  32. objXML.load Server.MapPath("emp_xml.xml")
  33. If objXML.parseError.errorCode <> 0 Then
  34.   'error found so show error message and stop
  35.   ShowError objXML
  36.   Response.End
  37. End If
  38.  
  39. 'load the XSL stylesheet and check for errors
  40. objXSL.load Server.MapPath("emp_style.xsl")
  41. If objXSL.parseError.errorCode <> 0 Then
  42.   'error found so show error message and stop
  43.   ShowError objXSL
  44.   Response.End
  45. End If
  46.  
  47. 'all must be OK, so perform transformation
  48. strResult = objXML.transformNode(objXSL)
  49.  
  50. 'and insert the results into the page
  51. Response.Write strResult
  52. %>
  53.